<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="geometry" content="interval">
  <link rel="stylesheet" href="./assets/common.css">
  <title>Rose Plot</title>
</head>

<body>
  <div id="canvas"></div>
  <script src="./assets/data-set.min.js"></script>
  <script src="../build/g2.js"></script>
  <script>
    const data = [
      { value: 335, name: '直接访问' },
      { value: 310, name: '邮件营销' },
      { value: 274, name: '联盟广告' },
      { value: 235, name: '视频广告' },
      { value: 400, name: '搜索引擎' }
    ];
    const chart = new G2.Chart({
      container: 'canvas',
      forceFit: true,
      height: window.innerHeight,
      padding: 0
    });
    const ds = new DataSet();
    const dv = ds.createView('demo')
      .source(data)
      .transform({
        field: 'value',
        type: 'sort'
      });
    chart.source(dv.rows);
    chart.coord('polar');
    chart.axis(false);
    chart.interval()
      .position('name*value')
      .color('name', [ '#CB5050', '#A72023', '#9D1F22', '#70171A', '#461012' ])
      .label('name');
    chart.render();
  </script>
</body>

</html>
